package br.ufrj.management.pages.virtual;



public class OperationalSystem{

	
	private static int n_max_threads; //the max number of threads allowed to exist in the simmulation
	private static long time_between_threads; //the time between two threads being created
	private static int process_ws_limit; //the workingset limit of a process
	private static int process_size_in_pages; //the size of the process in number of pages
	private static int memory_size_in_frames; //the size of the main memory in frames
	private static int n_request_calls_limit; //the number of page request calls between memory dumps
	
	public static void main(String[] args) {
		n_max_threads = 10;
		time_between_threads = 5000;
		memory_size_in_frames = 64;
		n_request_calls_limit = 4;
		
		process_ws_limit = 3;
		process_size_in_pages = 50;
		
		//initializing the log writer
		LogWriter.initialize("log_file.txt");
		
		//initializing the memory manager
		MemoryManager.initialize(memory_size_in_frames, n_max_threads, n_request_calls_limit);
		
		System.out.println("Execucao iniciada!");
		start_simulation(n_max_threads, time_between_threads, process_ws_limit, process_size_in_pages);
		
	}

	private static void start_simulation(int n_threads, long time_between_threads, int process_ws_limit, int process_size_in_pages) {
		
		SimThread auxThread;
		
		for(int i = 0; i < n_threads; i++){
			try{
				Thread.sleep(time_between_threads);
				auxThread = new SimThread(i, process_ws_limit, process_size_in_pages);
				MemoryManager.add_thread(auxThread);
			}
			catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
	}
	


}
